def extract_pokemon_names(input_file, output_file):
    with open(input_file, 'r', encoding='utf-8') as f:
        content = f.read().strip()

    # 分割所有字段
    fields = content.split('+')
    names = []
    i = 0

    while i < len(fields):
        # 检查当前字段是否为名称（后跟两个数字字段）
        if i + 2 < len(fields) and fields[i+1].isdigit() and fields[i+2].isdigit():
            names.append(fields[i])
            # 跳过名称和两个数字字段
            i += 3
        else:
            # 移动到下一个字段
            i += 1

    # 将名称列表连接成字符串
    result = '+'.join(names)

    # 写入输出文件
    with open(output_file, 'w', encoding='utf-8') as f:
        f.write(result)

# 使用示例
input_filename = 'pokedex_lanmei.txt'
output_filename = 'pokemon_names_lanmei.txt'
extract_pokemon_names(input_filename, output_filename)